package com.cosina.game.crystallight.ui.battle.drawable;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;

import com.cosina.game.crystallight.engine.BattleEngine;
import com.cosina.game.crystallight.ui.battle.BattleResource;
import com.cosina.game.crystallight.ui.battle.drawadapter.BaseDrawable;
import com.cosina.game.crystallight.ui.common.PaintSuite;
import com.cosina.game.crystallight.util.World;

public class ResultDrawable extends BaseDrawable{

	public Paint paint ;
	public ResultDrawable(){
		paint = new Paint();
		paint.setColor(Color.BLACK);
		paint.setAlpha(130);
	}
	
	@Override
	public void draw(Canvas canvas) {
		if(BattleEngine.status == BattleEngine.Status.running){
			return;
		}
		canvas.drawRect(0, 0, World.SCREEN_WIDTH, World.SCREEN_HEIGHT, paint);
		
		Bitmap bitmap = null;
		if(BattleEngine.status == BattleEngine.Status.victory){
			bitmap = BattleResource.victory;
		}
		if(BattleEngine.status == BattleEngine.Status.defeat){
			bitmap = BattleResource.defeat;
		}
		if(null == bitmap)
			throw new IllegalStateException("can't find bitmap for resuslt or wrong BattleControl status :" + BattleEngine.status);
		canvas.drawBitmap(bitmap, (World.SCREEN_WIDTH - bitmap.getWidth())/2, (44*9 - bitmap.getHeight())/2, PaintSuite.p4Simple);
	}
}
